package br.com.colegio.dao;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import br.com.colegio.dao.storage.Storage;
import br.com.colegio.vo.Configuracao;

public class ConfiguracaoDAO
{
	public static Collection<Object> list()
	{
		try
		{
			return Storage.select(Configuracao.class.getName(), null);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		return null;
	}

	public static Configuracao get(Long cod)
	{
		try
		{
			Object res = Storage.get(Configuracao.class.getName(), cod);

			if (res != null)
				return (Configuracao)res;
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		return null;
	}

	public static Collection<Object> getByDescricao(String des)
	{
		try
		{
			String params = "String p1";
			String filter = "descricao == p1";

			Map<String, Object> parVal = new HashMap<String, Object>();
			parVal.put("p1", des);

			return Storage.select(Configuracao.class.getName(), filter, params, parVal, null);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}

		return null;
	}

	public static Configuracao save(Configuracao reg) throws Exception
	{
		return (Configuracao)Storage.save(reg);
	}

	public static void delete(Long reg) throws Exception
	{
		Storage.delete(Configuracao.class.getName(), reg);
	}
}
